package com.sgb.kjwl.viewmodel.self.goods;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;

import com.sgb.kjwl.api.NewAPIManager;
import com.sgb.kjwl.model.entity.MemberPriceEntity;
import com.sgb.kjwl.model.entity.self.VipPriceMangeListEntity;
import com.sgb.kjwl.model.entity.user.OperationRecordItemEntity;
import com.swgk.core.base.model.entity.BaseEntity;
import com.swgk.core.common.base.BaseViewModel;

import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class OperationRecordViewModel extends BaseViewModel {

    public MutableLiveData<List<MemberPriceEntity.MemberPriceSkuDetail>> detailSku = new MutableLiveData<>();
    public MemberPriceEntity.ItemMemberList mdata;
    public OperationRecordViewModel(@NonNull @NotNull Application application) {
        super(application);
    }

    public MutableLiveData<MemberPriceEntity> detail = new MutableLiveData<>();



    /**
     * 获取sku会员价详情信息
     *
     * @param itemMemberNo
     * @param skuId
     */
    public void getSkuMemberPriceDetail(String itemMemberNo, String skuId) {
        mLoading.postValue(SHOW_LODING);
        NewAPIManager.getInstance().getGoodsAPI().getSkuMemberPriceDetail("item/member/getSkuMemberPriceDetail/" + itemMemberNo + "/" + skuId).enqueue(new Callback<BaseEntity<List<MemberPriceEntity.MemberPriceSkuDetail>>>() {
            @Override
            public void onResponse(Call<BaseEntity<List<MemberPriceEntity.MemberPriceSkuDetail>>> call, Response<BaseEntity<List<MemberPriceEntity.MemberPriceSkuDetail>>> response) {
                mLoading.postValue(DISMISS_LODING);
                if (response == null || response.body() == null) {
                    return;
                }
                if (response.body().getState().equals("ok")) {
                    detailSku.postValue(response.body().getData());
                } else {
                    mToast.postValue(response.body().getMsg());
                }
            }

            @Override
            public void onFailure(Call<BaseEntity<List<MemberPriceEntity.MemberPriceSkuDetail>>> call, Throwable t) {
                String msg = t.getMessage();
                mLoading.postValue(DISMISS_LODING);
            }
        });
    }
}
